package com.hdax.dmw.scheduler.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dmw.common.utils.Result;
import com.hdax.dmw.common.utils.ResultGenerator;
import com.hdax.dmw.entity.scheduler.SchedulerSeatPrice;
import com.hdax.dmw.scheduler.dtos.PriceDto;
import com.hdax.dmw.scheduler.dtos.SchedulerDto;
import com.hdax.dmw.scheduler.mapstruct.PriceDtoMapper;
import com.hdax.dmw.scheduler.mapstruct.SeatInfoMapper;
import com.hdax.dmw.scheduler.mapstruct.SeatPriceMapper;
import com.hdax.dmw.scheduler.service.SchedulerSeatPriceService;
import com.hdax.dmw.scheduler.mappers.SchedulerSeatPriceMapper;
import com.hdax.dmw.scheduler.service.SchedulerSeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author guoyisha
* @description 针对表【dm_scheduler_seat_price(节目排期座位价格表)】的数据库操作Service实现
* @createDate 2023-07-24 14:56:40
*/
@Service
public class SchedulerSeatPriceServiceImpl extends ServiceImpl<SchedulerSeatPriceMapper, SchedulerSeatPrice>
    implements SchedulerSeatPriceService{

    @Autowired
    private PriceDtoMapper priceDtoMapper;

    @Override
    public Result<List<PriceDto>> getPrice(Long scheduleId) {
        List<SchedulerSeatPrice> sources = list(new QueryWrapper<SchedulerSeatPrice>().eq("scheduleId", scheduleId));
        return ResultGenerator.genSuccessResult(priceDtoMapper.toTargetList(sources));
    }
    @Autowired
    private SeatPriceMapper seatPriceMapper;
    @Autowired
    private SeatInfoMapper seatInfoMapper;
    @Autowired
    private SchedulerSeatService seatService;

    @Override
    public Result<SchedulerDto> getSchedule(Long scheduleId) {
        SchedulerDto dto = new SchedulerDto();
        dto.setScheduleId(scheduleId.intValue());
        List<SchedulerSeatPrice> sources =
                list(new QueryWrapper<SchedulerSeatPrice>()
                        .eq("scheduleId", scheduleId));
        List<SchedulerDto.SeatPrice> seatPriceList = seatPriceMapper.toTargetList(sources);
        dto.setSeatPriceList(seatPriceList);

        List<SchedulerDto.SeatInfo> seatInfoList = seatInfoMapper.toTargetList(seatService.seatInfoList(scheduleId));
        dto.setSeatInfoList(seatInfoList);
        return ResultGenerator.genSuccessResult(dto);
    }
}




